package com.cdp.web.controller.system;
import com.cdp.common.core.domain.AjaxResult;
import com.cdp.common.core.domain.entity.Region;
import com.cdp.system.service.IRegionService;
import com.cdp.system.vo.RegionVO;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("")
public class RegionController {


    @Autowired
    private IRegionService regionService;


    /**
     * 查询地区集合
     * @return
     */
    //@GetMapping("query/region")
   // @PostMapping("/listMistedRegions")
    public AjaxResult queryRegion(){
        ArrayList<RegionVO> arrayList = new ArrayList<>();

        List<Region> list = regionService.list();
        for (Region region : list) {
            RegionVO regionVO = new RegionVO();
            BeanUtils.copyProperties(region,regionVO);
            arrayList.add(regionVO);
        }

        return AjaxResult.success(arrayList);
    }






}
